<template>
    <div>
        <h1>第一个页面</h1>
        <div>全局的数据为{{this.$store.state.num}}</div>
        <div>全局的数据 {{ num }}</div>
        <div>全局的数据 {{ n }}</div>
        <button  @click="fn">修改同步数据</button>
        <button  @click="fn1">修改异步数据</button>
    </div>
</template>
<script>
import  {mapState,mapMutations,mapActions} from  "vuex"
export default {
    data(){
        return  {num:99}
    },
    computed:{
        ...mapState(["num"]),
        ...mapState({//改名字
            n:'num'
        })
    },
    methods:{
        ...mapMutations(["changeNum"]),
        ...mapMutations({
            "addNum":"changeNum"
        }),
        ...mapActions(["asyncChangeNum"]),
        fn(){
            this.addNum(2000);
        },
        fn1(){
            this.asyncChangeNum(-10);
        }
       

    }

    
}
</script>